package com.gitee.wsl.ext.base

fun <A, B> Pair<A, B>.getOne() = first

fun <A, B> Pair<A, B>.getTwo() = second

operator fun <A : Comparable<A>, B : Comparable<B>> Pair<A, B>.compareTo(other: Pair<A, B>): Int {
    val first = first.compareTo(other.first)
    return if (first == 0) second.compareTo(other.second)
    else first
}

 fun <A, B> Pair<A, B>.joinToString(
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    firstTransform: (A) -> CharSequence = { it.toString() },
    secondTransform: (B) -> CharSequence = { it.toString() })
        = "$prefix${firstTransform(first)}$separator${secondTransform(second)}$postfix"


 fun <A, B, C> Triple<A, B, C>.joinToString(
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    firstTransform: (A) -> CharSequence = { it.toString() },
    secondTransform: (B) -> CharSequence = { it.toString() },
    thirdTransform: (C) -> CharSequence = { it.toString() })
        = "$prefix${firstTransform(first)}$separator${secondTransform(second)}$separator${thirdTransform(third)}$postfix"
